/* tests of format(n,w,p) */
/* Written by G.N.Ward */

#include bob:string.format

main()
{
  print(" tests of format(n,w,p)");
  w0 = 12; p0 = 3;
  print(" for w = ",w0,", p = ",p0);
  print("\n\n last characters should align with\n");
  print(format( "|", w0, p0 ),"  for w = ",w0,"\n");
  print(format( "|", w0, p0 ),"\n");

  format_test( -0.00178, w0, p0 );
  format_test(  0.0, w0, p0 );
  format_test(  1234.56789, w0, p0 );
  format_test( -1234.56789, w0, p0 );
  format_test(  123456789, w0, p0 );
  format_test( -123456789, w0, p0 );
  format_test( -54321, w0, p0 );
  format_test(  0.999999, w0, p0 );
  format_test( -0.999999, w0, p0 );
  format_test( -0.00001, w0, p0 );
  format_test( 0, w0, p0);
  format_test( "test string", w0, p0 );
}

format_test(n,w,p)
{
  switch (typeof(n))
    {
      case REAL   :type$ = "real n:    ";break;
      case INTEGER:type$ = "integer n: ";break;
      case STRING :type$ = "string n:  ";
    }   
  print(format(n,w0,p0),"  for ",type$,n,"\n");
  print(format("|",w0,p0),"\n");
}

